﻿using System;
using System.Windows.Forms;
using v8sharp;

namespace HostingSample
{
	static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() {
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);

			V8Engine engine = V8Engine.Create();
			
			var window = new MainWindow(engine) {
				Text = "Main Window"
			};
			var application = new MainApplication {
				ApplicationName = "HostingSample",
				Version = "v1.0",
				Window = window
			};			
			var messageService = new MessageService {
				Window = window
			};
			
			engine.Register<IApplication>("Application", application);
			engine.Register<IWindow>("Window", window);
			engine.Register<IApplicationConsole>("Console", window);
			engine.Register<IMessageService>("MessageService", messageService);
			engine.Register<Point>();

			engine.RegisterFunction("printmsg", new Action<string>(message => ((IApplicationConsole)window).Write(message)));

			Application.Run(window);
		}
	}
}
